home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw™ GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Ligature Splits.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  1.7 KB  |  83 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Windows.h>
  5. #include <Menus.h>
  6. #include <SegLoad.h>
  7. #include <Memory.h>
  8. #include <Desk.h>
  9.  
  10. #include "graphics routines.h"
  11. #include "graphics libraries.h"
  12. #include "graphics toolbox.h"
  13.  
  14. #include "layout types.h"
  15. #include "layout routines.h"
  16. #include "layout library.h"
  17.  
  18. #include "SampleInterface.h"
  19.  
  20. short MyStrLen(char *x);
  21. static short MyStrLen(x)
  22. char    *x;
  23.     {
  24.     short c = 0;
  25.     while (*x++) c++;
  26.     return c;
  27.     }    /* MyStrLen */
  28.  
  29. void LigatureSplits(WindowPtr sampleWindow)
  30.     {
  31.     /* Variables */
  32.     char        *myString = "fly fishing";
  33.     gxPoint        myPoint;
  34.     gxRunControls    gxRunControls;
  35.     gxShape        caret, layout;
  36.     short        i, len, level = 0;
  37.     gxStyle        myStyle;
  38.     gxViewPort    aViewPort;
  39.     
  40.     /* Initialization */
  41.     
  42.     myPoint.x = ff(20);
  43.     myPoint.y = ff(50);
  44.     
  45.     aViewPort = GXNewWindowViewPort(sampleWindow);
  46.     SetDefaultViewPort(aViewPort);
  47.     
  48.     len = MyStrLen(myString);
  49.     InitializeRunControls(&gxRunControls);
  50.  
  51.     myStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  52.     
  53.     layout = GXNewLayout(
  54.         1, &len, (void *) &myString,
  55.         1, &len, &myStyle,
  56.         1, &len, &level,
  57.         nil, &myPoint);
  58.     GXDrawShape(layout);
  59.     
  60.     for (i = 0; i < len; i++)
  61.         {
  62.         caret = GXGetLayoutCaret(layout, i, gxHighlightAverageAngle, gxSplitCaretType, nil);
  63.         GXDrawShape(caret);
  64.         GXDisposeShape(caret);
  65.         }
  66.     
  67.     gxRunControls.flags = gxNoLigatureSplits;
  68.     GXSetStyleRunControls(myStyle, &gxRunControls);
  69.     GXMoveShape(layout, 0, ff(75));
  70.     GXDrawShape(layout);
  71.     
  72.     for (i = 0; i < len; i++)
  73.         {
  74.         caret = GXGetLayoutCaret(layout, i, gxHighlightAverageAngle, gxSplitCaretType, nil);
  75.         GXDrawShape(caret);
  76.         GXDisposeShape(caret);
  77.         }
  78.     
  79.     GXDisposeShape(layout);
  80.     GXDisposeStyle(myStyle);
  81.     GXDisposeViewPort(aViewPort);
  82.     }    /* main */
  83.